#include <stdio.h>
#include <omp.h>
#include <time.h>
#include <stdlib.h>
//编译指令
//gcc -std=c99 -fopenmp 10Master.c -o cmake-build/10Master && export OMP_NUM_THREADS=512 && time ./cmake-build/10Master


int main()
{
    int i,a=0;
    int b[6];
#pragma omp parallel private(i) shared(a,b)  default(none)
    {
#pragma omp master //只有主线程执行以下代码段
        {
            a=10;
            printf("Master construct is executed by thread %d\n",omp_get_thread_num());
        }
#pragma omp barrier
        #pragma omp for
        for(i=0;i<6;i++)
            b[i]=a;
    }
    printf("After parallel region:\n");
    for(i=0;i<6;i++)
        printf("b[%d]=%d\n",i,b[i]);
    return 0;
}
